Skip to main content

Input

Input supports keys and touch. Keys and touch are derived from hardware devices. Different devices may only support one of them. Touch devices will enable the touch function by default and simulate keys.

btn

btn([B])

Get button status (pressed/released).

B: 0..7: key number.

If there is no parameter B, the function returns the state of all keys, using bit to represent the state of each key.

btnp

btnp(B)

btnp returns to the click state of the button, released in the previous frame, and returns true when it is currently pressed. If it is kept pressed, btnp will return a click every 4 frames after 15 frames. The time parameter of click repetition can be carried out through btnpcfg Configuration modification.

btnpcfg

btnpcfg(delay,interval)

delay: The number of frames to delay before double-clicking the button.

interval: Combo interval frame number.

btnpcfg(255,0) -- disable combos

inputcfg

inputcfg(opt)

inputcfg configures touch and key functions, and returns to the last configuration.

opt.bit0 - enable touch mode

opt.bit1 - enable touch simulation button mode

touch

touch()

Query the touch status and return the x, y, stat, hotid, rectidx of the touch.

x, y, stat represent the touch position and state, when stat is 0, x, y are the last released position.

hotid is the serial number of the hot zone.

rectidx is the number of the rectangle inside the hot zone.

touchdef

touchdef(hotid,flag,x0,y0,x1,y1[,rectidx])

Define a touch hotspot, if no parameter is passed, it means clear all hotspots.

hotid: hot zone number 1..n, hot zone with the same number can be defined multiple times, equivalent to hot zone union, use rectidx to distinguish sub-regions.

flag: hot zone option, 1 means consume touch events (touch events will not be passed to the background frame).

x0,y0,x1,y1: hotspot rectangle. if x0 is a table, then use polygon defined by x0, the most points is 8. ex: {x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6}

rectidx: area number, default 1.